package com.xdf.ecommerce.controller;

import com.xdf.ecommerce.service.communication.AuthorityFeignClient;
import com.xdf.ecommerce.service.communication.UseRestTemplateService;
import com.xdf.ecommerce.service.communication.UseRibbonService;
import com.xdf.ecommerce.vo.JwtToken;
import com.xdf.ecommerce.vo.UsernameAndPassword;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author chanchaw
 * @create 2025-10-29 10:01
 */
@RequiredArgsConstructor
@CrossOrigin
@RestController
@RequestMapping("/communication")
public class CommunicationController {
    private final AuthorityFeignClient feignClient;
    private final UseRestTemplateService restTemplateService;
    private final UseRibbonService ribbonService;
    @PostMapping("/getToken8LoadBalancer")
    public JwtToken getToken8LoadBalancer(@RequestBody UsernameAndPassword uap){
        return restTemplateService.getToken8LoadBalancer(uap);
    }
    @PostMapping("/getTokenNoLoadBalancer")
    public JwtToken getTokenNoLoadBalancer(@RequestBody UsernameAndPassword uap){
        return restTemplateService.getToken(uap);
    }
    @PostMapping("/getTokenRibbon")
    public JwtToken getTokenRibbon(@RequestBody UsernameAndPassword uap){
        return ribbonService.getToken(uap);
    }
    @PostMapping("/getTokenOpenFeign")
    public JwtToken getTokenOpenFeign(@RequestBody UsernameAndPassword uap){
        return feignClient.getToken(uap);
    }
}
